#pragma once

class COptimizeDlg : public CDialogImpl<COptimizeDlg>, public CMessageFilter
{
public:
	enum { IDD = IDD_OPTMIZE };

	BEGIN_MSG_MAP(COptimizeDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
		COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
	END_MSG_MAP()

	CButton m_btnCancel;
	CStatic m_sttCount;
	CStatic m_sttFile;

	kThread* m_thd;
	kHfs* m_hfs;
	tpl::BlueStr<260> m_original;
	tpl::BlueStr<260> m_filename;
	int m_cnt;

	BOOL PreTranslateMessage(MSG* pMsg);
	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	void CloseDialog(int nVal);

	void Start(kHfs* hfs, const char* original, const char* filename);

private:
	void WorkThd();
	void OnOptimize(int stack, const char* filename);

	static kpointer StaticWorkThd(kpointer ptr);
};
